import http from '.'
/**
 * 查询小区
 */
export function queryCommunity(params) {
  return http.get('api/v1/community/query?' + Form(params).queryString())
}
/**
 *  删除小区
 * @param {*} rowId
 */
export function deleteCommunity(rowId) {
  return http.post('api/v1/community/delete?rowId=' + rowId)
}
/**
 * 增加小区
 * @param {*} params
 */
export function saveCommunity(params) {
  return http.post(
    `api/v1/community/${params.rowId ? 'updateCommunity' : 'addCommunity'}`,
    Form(params)
  )
}
/**
 * 查询小区详情
 * @param {*} rowId
 */
export function queryCommunityDetail(rowId) {
  return http.get('api/v1/community/detail?rowId=' + rowId)
}
/**
 * 添加、修改楼栋
 * @param {*} params
 */
export function saveBulidIng(params) {
  return http.post(`api/v1/project/addProject?`, Form(params))
}
// ----------------项目接口-----------------//
/**
 * 添加项目
 * @param {*} params
 */
export function saveProject(params) {
  return http.post(`api/v1/project/addProject?`, Form(params))
}
/**
 * 修改项目
 * @param {} params
 */
export function updateProject(params) {
  return http.post(`api/v1/project/edit?`, Form(params))
}
/**
 * 修改项目
 * @param {} params
 */
export function queryProject(params) {
  return http.get('api/v1/project/queryProject?' + Form(params).queryString())
}
/**
 * 查询项目详情
 * @param {*} rowId
 */
export function queryProjectDetail(rowId) {
  return http.get('api/v1/project/detail?rowId=' + rowId)
}
/**
 * 删除项目
 * @param {*} rowId
 */
export function deleteProject(rowId) {
  return http.post('api/v1/project/delete?rowId=' + rowId)
}
// ----------------企业接口-----------------//
/**
 * 修改企业
 * @param {} params
 */
export function updateBussiness(params) {
  return http.post(`api/v1/bussiness/edit?`, Form(params))
}
/**
 * 添加企业
 * @param {*} params
 */
export function saveBussiness(params) {
  return http.post(`api/v1/bussiness/addBussiness?`, Form(params))
}
/**
 * 删除企业
 * @param {*} rowId
 */
export function deleteBussiness(rowId) {
  return http.post('api/v1/bussiness/delete?rowId=' + rowId)
}
/**
 * 查询企业详情
 * @param {*} rowId
 */
export function queryBussinessDetail(rowId) {
  return http.get('api/v1/bussiness/detail?rowId=' + rowId)
}

/**
 * 企业设备关系
 * @param {*} rowId
 */
export function getBussinessDetail(rowId) {
  return http.get('api/v1/bussiness/getBussinessDetail?rowId=' + rowId)
}
// ----------------楼宇接口-----------------//
/**
 * 批量添加楼栋
 */
export function uploadBuildingFile(excel) {
  return http.post('api/v1/building/insertBatch', excel)
}

/**
 * 查询楼栋
 * @param {*} params
 */
export function queryBulidIng(params) {
  return http.get(
    'api/v1/bussiness/queryBussiness?' + Form(params).queryString()
  )
}

// 查询住户
export function queryResidentByPage(params) {
  return http.get('api/v1/userHouse/query?' + Form(params).queryString())
}
/**
 * 删除楼栋
 * @param {*} rowId
 */
export function deleteBulidIng(rowId) {
  return http.post('api/v1/building/delete?rowId=' + rowId)
}
/**
 * 查询楼栋详情
 * @param {*} rowId
 */
export function querBuildingDetail(rowId) {
  return http.get('api/v1/building/detail?rowId=' + rowId)
}

/**
 * 根据小区id查楼栋
 * @param {*} rowId
 */
export function selectByCommunityIdBuilding(rowId) {
  return http.get(
    'api/v1/building/selectByCommunityIdBuilding?communityId=' + rowId
  )
}
/**
 * 根据区县id查找企业
 * @param {*} rowId
 */
export function selectByCommunityIdBussiness(rowId) {
  return http.get(
    'api/v1/bussiness/selectByCommunityIdBussiness?districtId=' + rowId
  )
}
/**
 * 添加单元
 * @param {*} params
 */
export function saveUnit(params) {
  return http.post(
    `api/v1/unit/${params.rowId ? 'updateUnit' : 'addUnit'}`,
    Form(params)
  )
}
/**
 * 批量添加单元
 */
export function uploadUnitFile(excel) {
  return http.post('api/v1/unit/insertBatch', excel)
}
/**
 * 查询单元
 * @param {*} params
 */
export function queryUnit(params) {
  return http.get('api/v1/unit/query?' + Form(params).queryString())
}
/**
 * 删除单元
 * @param {*} rowId
 */
export function deleteUnit(rowId) {
  return http.post('api/v1/unit/delete?rowId=' + rowId)
}

/**
 * 根据企业查询项目
 * @param {*} rowId
 */
export function findProjectByBussiness(rowId) {
  return http.get('api/v1/project/findProjectByBussinessId')
}
/**
 * 查询单元详情
 * @param {*} rowId
 */
export function querUnitDetail(rowId) {
  return http.get('api/v1/unit/detail?rowId=' + rowId)
}
/**
 * 根据楼栋id查询单元
 * @param {*} rowId
 */
export function selectByBuildingUnit(rowId) {
  return http.get('api/v1/unit/selectByBuildingUnit?buildingId=' + rowId)
}
/**
 * 增加修改房屋
 * @param {*} params
 */
export function saveHouse(params) {
  return http.post(
    `api/v1/house/${params.rowId ? 'updateHouse' : 'addHouse'}`,
    Form(params)
  )
}

/**
 * 批量添加楼栋
 */
export function uploadHouseFile(excel) {
  return http.post('api/v1/house/insertBatch', excel)
}
/**
 * 查询楼层
 * @param {*} params
 */
export function getFloor(rowId) {
  return http.get('api/v1/floor/selectAllFloor?unitId=' + rowId)
}
/**
 * 查询楼层详情
 * @param {*} rowId
 */
export function querFloorDetail(rowId) {
  return http.get('api/v1/floor/detail?rowId=' + rowId)
}

/**
 * 查询房屋
 * @param {*} params
 */
export function queryHouse(params) {
  return http.get('api/v1/house/query?' + Form(params).queryString())
}
/**
 * 删除房屋
 * @param {*} rowId
 */
export function deleteHouse(rowId) {
  return http.post('api/v1/house/delete?rowId=' + rowId)
}
/**
 * 查询房屋详情
 * @param {*} rowId
 */
export function querHouseDetail(rowId) {
  return http.get('api/v1/house/detail?rowId=' + rowId)
}
/**
 * 查询门列表
 * @param {*} params
 */
export function queryDoor(params) {
  return http.get('api/v1/door/query?' + Form(params).queryString())
}
/**
 * 删除门
 * @param {*} rowId
 */
export function deleteDoor(rowId) {
  return http.post('api/v1/door/delete?rowId=' + rowId)
}
/**
 * 增加编辑门
 * @param {*} params
 */
export function saveDoor(params) {
  return http.post(
    `api/v1/door/${params.rowId ? 'edit' : 'addDoor'}`,
    Form(params)
  )
}
/**
 * 查询门详情
 * @param {*} doorId
 */
export function querDoorDetail(doorId) {
  return http.get('api/v1/door/detail?rowId=' + doorId)
}
/**
 * 查询小区门信息
 * @param {*} params
 */
export function selectCommunityDoor(params) {
  return http.get('api/v1/doorCommunity/query?' + Form(params).queryString())
}
/**
 * 查询单元门信息
 * @param {*} params
 */
export function selectDoorUnit(params) {
  return http.get('api/v1/doorUnit/query?' + Form(params).queryString())
}
/**
 * 查询特殊门信息
 * @param {*} params
 */
export function selectHouseDoor(params) {
  return http.get('api/v1/doorHouse/query?' + Form(params).queryString())
}
/**
 * 根据区县id查询所有企业
 * @param {*} rowId
 */
export function selectAllCommunity(rowId) {
  return http.get('api/v1/community/selectAllBussiness?districtId=' + rowId)
}
/**
 * 根据小区id查询所有单元
 * @param {*} rowId
 */
export function selectAllUnit(rowId) {
  return http.get('api/v1/unit/selectAllUnit?communityId=' + rowId)
}
/**
 * 根据单元id查询所有房屋
 * @param {*} rowId
 */
export function selectAllHouse(rowId) {
  return http.get('api/v1/house/selectAllHouse?unitId=' + rowId)
}
/**
 * 查询室下住户信息
 * @param {*} rowId
 */
export function selectResidentByHouseId(rowId) {
  return http.get('api/v1/memberUser/selectResidentByHouseId?houseId=' + rowId)
}
/**
 * 删除住户
 * @param {*} rowId
 */
export function deleteResident(rowId) {
  return http.post('api/v1/userHouse/delete?rowId=' + rowId)
}
/**
 * 设置视频通话
 * @param {*} params
 */
export function editVideoCall(params) {
  return http.post('api/v1/memberUser/edit', Form(params))
}
/**
 * 升级成为管理员
 * @param {*} params
 */
export function upgradeOwner(params) {
  return http.post('api/v1/userHouse/upgradeOwner', Form(params))
}
/**
 * 查询设备
 */
export function selectDevice() {
  return http.get('api/v1/device/selectDevice')
}
/**
 *  查询设备详情
 * @param {*} rowId
 */
export function selectDeviceDoor(rowId) {
  return http.get('api/v1/device/deviceDoor/selectDeviceDoor?doorId=' + rowId)
}
/**
 * 绑定设备
 * @param {*} params
 */
export function addDoorDevice(params) {
  return http.post('api/v1/device/addDoorDevice', Form(params))
}
/**
 * 解绑门禁设备
 * @param {*} doorId
 */
export function deleteDoorDevice(doorId) {
  return http.post('api/v1/device/deviceDoor/delete?doorId=' + doorId)
}
/**
 * 查询电源设备
 */
export function selectPowerDevice() {
  return http.get('api/v1/power/selectPowerDevice')
}
/**
 * 查询电源设备门详情
 * @param {*} rowId
 */
export function selectPowerDeviceById(rowId) {
  return http.get('api/v1/powerDoor/selectPowerDeviceById?doorId=' + rowId)
}
/**
 * 门绑定电源设备
 * @param {*} params
 */
export function addDoorPowerDevice(params) {
  return http.post('api/v1/powerDoor/addPowerDoor', Form(params))
}
/**
 * 添加门卡人关系
 * @param {*} params
 */
export function saveDoorCardUserReal(params) {
  return http.post('api/v1/card/houseUserReal/addHouseUserReal', Form(params))
}
/**
 * 解绑电源设备
 * @param {*} doorId
 */
export function deletePowerDevice(doorId) {
  return http.post('api/v1/powerDoor/delete?doorId=' + doorId)
}
/**
 * 更改优先级
 * @param {*} params
 */
export function updatePriority(params) {
  return http.post(
    'api/v1/userHouse/updatePriority?' + Form(params).queryString()
  )
}
/**
 * 根据房间编号查询卡列表
 */
export function queryDoorCardNoAndExpDateByHouseId(rowId) {
  return http.get(
    'api/v1/card/house/queryDoorCardNoAndExpDateByHouseId?rowId=' + rowId
  )
}
/**
 * 查询该室下未绑定的人的门卡
 */
export function queryDoorCardByHouseId(houseId) {
  return http.get('api/v1/card/house/queryDoorCardByHouseId?houseId=' + houseId)
}
/**
 * 根据卡批次查询为绑定使用的卡号(普通门卡)
 */
export function queryDoorCardByBatchNo(batchNo, communityId, type) {
  return http.get(
    'api/v1/card/doorCard/queryDoorCardByBatchNo?batchNo=' +
      batchNo +
      '&communityId=' +
      communityId +
      '&type=' +
      type
  )
}
/**
 * 添加卡同时修改卡状态
 * @param {*} params
 */
export function addDoorCardHouseAndUpdateDoorCard(params) {
  return http.post(
    'api/v1/card/house/addDoorCardHouseAndUpdateDoorCard',
    Form(params)
  )
}
/**
 * 发卡时后台入库序列号
 */
export function editDoorCard(rowId, serialNumber) {
  return http.post(
    'api/v1/card/doorCard/edit?rowId=' + rowId + '&serialNumber=' + serialNumber
  )
}

/**
 * 延期
 */
export function editDoorCardDelay(rowId, expdate) {
  return http.post(
    'api/v1/card/doorCard/edit?rowId=' + rowId + '&expdate=' + expdate
  )
}
/**
 * 设备绑定的单元下有多少人
 * @param {*} params
 */
export function selectUserCountByUnitBindDevice(params) {
  return http.get(
    'api/v1/doorUnit/selectUserCountByUnitBindDevice?' +
      Form(params).queryString()
  )
}
/**
 * 导出excel
 * @param {*} params
 */
export function doExport(params) {
  return http.post('api/v1/doorUnit/doExport?' + Form(params))
}
